package com.game.job;

import com.game.pool.DataPool;
import com.game.hot.Manager;
import com.nets.pool.ServerPool;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * @author sig
 * @since 2016/9/28
 */
public class SimpleJob implements Job {

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        if (!ServerPool.startupFinish) return;
        Manager.getTimeMg().sec3();

        long current = System.currentTimeMillis();
        long temp = current - 3 * DataPool.SECOND;

        if (current > DataPool.min) {
            DataPool.min = temp + DataPool.MINUTE;
            Manager.getTimeMg().min();
        }

        if (current > DataPool.min3) {
            DataPool.min3 = temp + 3 * DataPool.MINUTE;
            Manager.getTimeMg().min3();
        }

        if (current > DataPool.min5) {
            DataPool.min5 = temp + 5 * DataPool.MINUTE;
            Manager.getTimeMg().min5();
        }

        if (current > DataPool.min10) {
            DataPool.min10 = temp + 10 * DataPool.MINUTE;
            Manager.getTimeMg().min10();
        }

        if (current > DataPool.min30) {
            DataPool.min30 = temp + 30 * DataPool.MINUTE;
            Manager.getTimeMg().min30();
        }

        if (current > DataPool.hour) {
            DataPool.hour = temp + DataPool.HOUR;
            Manager.getTimeMg().hour();
        }

        if (current > DataPool.day) {
            DataPool.day = temp + DataPool.DAY;
            Manager.getTimeMg().day();
        }

        if (current > DataPool.week) {
            DataPool.week = temp + DataPool.WEEK;
            Manager.getTimeMg().week();
        }
    }
}
